//
//  ShuwuCell.m
//  HomeIn
//
//  Created by dllo on 15/11/9.
//  Copyright © 2015年 ZZP. All rights reserved.
//

#import "ShuwuCell.h"
#import "ShuwuModel.h"

@implementation ShuwuCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self creataSubviews];
    }
    return  self;
}

- (void)creataSubviews
{
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    //图片
    self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height / 3 * 2)];
    //self.imageView.backgroundColor = [UIColor cyanColor];
    [self.contentView addSubview:self.imageView];
    
    //名字
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, self.imageView.frame.size.height, self.imageView.frame.size.width - 10, self.contentView.frame.size.height / 3 / 2)];
    //self.nameLabel.backgroundColor = [UIColor orangeColor];
    [self.contentView addSubview:self.nameLabel];
    
    //喜欢
    self.likeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, self.imageView.frame.size.height + self.nameLabel.frame.size.height, self.nameLabel.frame.size.width - 10, self.contentView.frame.size.height - self.imageView.frame.size.height - self.nameLabel.frame.size.height)];
    //self.priceLabel.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.likeLabel];
    

}

- (void)setShuwuModel:(ShuwuModel *)shuwuModel
{
    _shuwuModel = shuwuModel;
    
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:_shuwuModel.cover_image_url]];
    
    self.nameLabel.text = _shuwuModel.short_title;
    self.nameLabel.textAlignment = NSTextAlignmentLeft;
    self.nameLabel.lineBreakMode = NSLineBreakByWordWrapping;
    self.nameLabel.numberOfLines = 0;
    self.nameLabel.font = [UIFont systemFontOfSize:17];
    
    
    self.likeLabel.text = [NSString stringWithFormat:@"喜欢: %ld",_shuwuModel.likes_count];
    self.likeLabel.textColor = [UIColor lightGrayColor];
}

@end
